package com.bot.nft.module.dc.service.impl;

import cn.hutool.log.Log;
import cn.hutool.log.LogFactory;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bot.nft.module.dc.domain.DcBillLog;
import com.bot.nft.module.dc.domain.vo.DcBillLogVo;
import com.bot.nft.module.dc.mapper.DcBillLogMapper;
import com.bot.nft.module.dc.service.IDcBillLogService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author RenXiaoZheng
 * @since 2024-01-24
 */
@Service
public class DcBillLogServiceImpl extends ServiceImpl<DcBillLogMapper, DcBillLog> implements IDcBillLogService {

    //日志
    private static final Log log = LogFactory.get();

    //mapper
    @Resource
    private DcBillLogMapper dcBillMapper;

    /**
     * 查询藏品交易账单
     *
     * @param type     收支类型
     * @param pageNo   当前第几页
     * @param pageSize 每页显示多少条数据
     * @return
     */
    @Override
    public Page<DcBillLogVo> queryDcBillLog(Integer type, Integer pageNo, Integer pageSize) {
        log.info("开始查询交易账单根据账单类型{}", type);
        //分页查询藏品交易账单信息
        Page<DcBillLogVo> page = new Page<>(pageNo, pageSize);
        Page<DcBillLogVo> dcBillLogs = dcBillMapper.selectDcBillLog(type, page);
        log.info("查询交易账单结束根据账单类型{}", type);
        return dcBillLogs;
    }

    /**
     * 查看藏品交易订单
     *
     * @param id 藏品交易账单标识
     * @return
     */
    @Override
    public DcBillLogVo getDcBillLog(String id) {
        //查看藏品交易账单信息
        log.info("开始查看交易账单{}", id);
        DcBillLogVo dcBillLogVo = dcBillMapper.queryDcBill(id);
        log.info("查看交易账单{}", dcBillLogVo.getTrader());
        return dcBillLogVo;
    }

    /**
     * 导出藏品账单
     *
     * @return
     */
    @Override
    public List<DcBillLogVo> exportDcBillLog(Integer type, Date billTime, Date endTime) {
        //导出藏品账单信息
        log.info("开始导出交易账单根据时间{}跟之间{}和账单类型{}", billTime, endTime, type);
        List<DcBillLogVo> dcBillLogVos = dcBillMapper.exportDcBill(type, billTime, endTime);
        log.info("根据时间{}跟之间{}和账单类型{}查看完成", billTime, endTime, type);
        return dcBillLogVos;
    }

}
